

package jetbrains.buildServer.server.rest.data.util;

import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Nullable;

/**
 * @author Yegor.Yarko
 *         Date: 10.04.13
 */
public class FilterUtil {
  public static boolean isIncludedByBooleanFilter(@Nullable final Boolean filterValue, @Nullable final Boolean actualValue) {
    return filterValue == null || actualValue == null || (!(filterValue ^ actualValue));
  }

  @Contract("true -> true; null -> true; false -> false")
  public static boolean isIncludingBooleanFilter(@Nullable final Boolean value) {
    return value == null || value;
  }

  @Contract("true -> true; null -> false; false -> false")
  public static boolean isTrue(@Nullable final Boolean value) {
    return value != null && value;
  }
}